import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import layout from '../views/layout/index.vue'

const routes: Array<RouteRecordRaw> = [
  // 首页
  { path: '/', redirect: '/home/dashboard' },
  {
    path: '/home',
    name: 'home',
    component: layout,
    meta: { "title": "首页", "icon": 'icon-panel', "type": "2" },
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        meta: { "title": "仪表盘", "type": "2" },
        component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue')
      },
      {
        path: 'data',
        name: 'data',
        meta: { "title": "设备数据", "type": "2" },
        component: () => import(/* webpackChunkName: "data" */ '../views/dashboard/data.vue')
      },
    ]
  },
  // 设备
  {
    path: '/device',
    name: 'device',
    component: layout,
    meta: { "title": "设备", "icon": 'icon-luyouqi', "type": "2" },
    children: [
      {
        path: 'gateway',
        name: 'gateway',
        meta: { "title": "网关", "type": "2" },
        component: () => import(/* webpackChunkName: "gateway" */ '../views/device/GatewayView.vue')
      },
      {
        path: 'sensor',
        name: 'sensor',
        meta: { "title": "传感器列表", "type": "2" },
        component: () => import(/* webpackChunkName: "sensor" */ '../views/device/SensorList.vue')
      },
      {
        path: 'groud',
        name: 'groud',
        meta: { "title": "设备群组", "type": "2" },
        component: () => import(/* webpackChunkName: "groud" */ '../views/device/DeviceGroud.vue')
      },
    ]
  },
  // // 计费
  {
    path: '/jifei',
    name: 'jifei',
    component: layout,
    meta: { "title": "计费", "icon": 'icon-fyxx', "type": "2" },
    children: [
      {
        path: 'accountinfo',
        name: 'accountinfo',
        meta: { "title": "账户信息", "type": "2" },
        component: () => import(/* webpackChunkName: "accountinfo" */ '../views/jifei/AccountInfo.vue')
      },
      {
        path: 'pay',
        name: 'pay',
        meta: { "title": "充值记录", "type": "2" },
        component: () => import(/* webpackChunkName: "pay" */ '../views/jifei/PayRecord.vue')
      },
      {
        path: 'use',
        name: 'use',
        meta: { "title": "使用记录", "type": "2" },
        component: () => import(/* webpackChunkName: "use" */ '../views/jifei/UseRecord.vue')
      },
    ]
  },
  // 测量类型
  {
    path: '/measure',
    name: 'measure',
    component: layout,
    meta: { "title": "测量类型", "icon": 'icon-signal', "type": "2" },
    children: [
      {
        path: 'addtype',
        name: 'addtype',
        meta: { "title": "添加测量类型", "type": "2" },
        component: () => import(/* webpackChunkName: "addtype" */ '../views/celiangleixing/AddType.vue')
      },
      {
        path: 'typelist',
        name: 'typelist',
        meta: { "title": "测量类型列表", "type": "2" },
        component: () => import(/* webpackChunkName: "typelist" */ '../views/celiangleixing/TypeList.vue')
      }
    ]
  },
  // 安全
  {
    path: '/safety',
    name: 'safety',
    component: layout,
    meta: { "title": "安全", "icon": 'icon-anquan', "type": "1" },
    children: [
      {
        path: 'addkey',
        name: 'addkey',
        meta: { "title": "添加密钥", "type": "1" },
        component: () => import(/* webpackChunkName: "addkey" */ '../views/safety/AddKey.vue')
      },
      {
        path: 'keylist',
        name: 'keylist',
        meta: { "title": "密钥列表", "type": "1" },
        component: () => import(/* webpackChunkName: "keylist" */ '../views/safety/KeyList.vue')
      }
    ]
  },
  // 账号
  {
    path: '/account',
    name: 'account',
    component: layout,
    meta: { "title": "账号", "icon": 'icon-account', "type": "1" },
    children: [
      {
        path: 'addaccount',
        name: 'addaccount',
        meta: { "title": "添加账号", "type": "1" },
        component: () => import(/* webpackChunkName: "addkey" */ '../views/account/AddAccount.vue')
      },
      {
        path: 'accountlist',
        name: 'accountlist',
        meta: { "title": "账号列表", "type": "1" },
        component: () => import(/* webpackChunkName: "keylist" */ '../views/account/AccountList.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {
    path: '/:error*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
